package com.lins.framework.ui.home.product;

import com.lins.framework.http.util.Networks;

import java.util.ArrayList;

import rx.Subscriber;

/**
 * Created by Admin on 2017/3/14.
 */

public class ProductListPresenter extends ProductListContract.Presenter {
    @Override
    void getProductList(int catid) {
        mRxManager.add(mModel.getProductList(catid)
                .map(new Networks.HttpResultFunc<ProductListBean>())
                .subscribe(new Subscriber<ProductListBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.onRequestError(e.getMessage());
                    }

                    @Override
                    public void onNext(ProductListBean productListBean) {
                        mView.setBtnText(productListBean);
                    }
                }));
    }

    @Override
    void getTopBanner(int catid) {
        mRxManager.add(mModel.getTopBanner(catid)
                .map(new Networks.HttpResultFunc<ArrayList<TopBannerBean>>())
                .subscribe(new Subscriber<ArrayList<TopBannerBean>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.onRequestError(e.getMessage());
                    }

                    @Override
                    public void onNext(ArrayList<TopBannerBean> topBannerBeen) {
                        mView.setBannerData(topBannerBeen);
                    }
                }));
    }
}
